def consumer():
    n = 0
    while True:
        n = yield n
        print(n)
        if not n:
            return
        n -= 1
def produce(c):
    n = 0
    next(c)
    while n < 6:
        n += 2
        n = c.send(n)
        
    c.close()
    
c = consumer()
produce(c)